﻿using System.Collections.Generic;
using System.Threading.Tasks;
using Jinjia.Approve.Model.Input.JJFlow;
using Jinjia.Approve.Model.VM;
using Jinjia.Approve.Model.VM.JJFlow;
using Jinjia.Approve.Model.VM.JJFlow.DTO;
using Jinjia.Approve.Model.VM.JJFlow.Request;
using Jinjia.Core.BaseInfrastructure.BaseModel.BaseModel;
using Jinjia.Core.BaseInfrastructure.StorageModel.Model;

namespace Jinjia.Approve.IService.JJFlow
{
    public interface IJJFlowService
    {
        /// <summary>
        /// 发起审批
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<NodeInfo> Create(CreateRequest request);
        
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<NodeInfo> Approve(CreateRequest request);

        /// <summary>
        /// 自动审核
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<int?> AutoApprove(AutoApproveRequest request);

        /// <summary>
        /// 驳回审批
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<int> Reject(CreateRequest request);

        /// <summary>
        /// 撤回
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<int> Recall(ReCallRequest request);

        /// <summary>
        /// 查询轨迹 (公用)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<List<JjFlowTrackVM>> GetFlowTrackList(CreateRequest request);

        /// <summary>
        /// 查询已完成审批的节点
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<List<EmpInfo>> GetCompletedNodeList(CreateRequest request);
        
        /// <summary>
        /// 记录模块查阅日志
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<string> ViewedLog(CreateRequest request);
        
        /// <summary>
        /// 查询模块的查阅记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<List<ErpaViewedLogViewModel>> GetViewedLog(CreateRequest request);
        
        /// <summary>
        /// 复制审批流记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<ResponseResult<string>> CopyJJFlowTrack(CopyJJFlowRequest request);

        /// <summary>
        /// 获取用户是否有待审核数据权限
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> GetUserPower(QueryRequest request);

        /// <summary>
        /// 查询待办审批
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<List<string>> GetUserBizOrderId(QueryRequest request);
        /// <summary>
        /// 首页-待办 汇总页
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageListSearchResultVM<MyTodoListOverview>> GetMyTodoList(SearchConditionBaseInput input);
        /// <summary>
        /// 首页 待办 汇总也的总条数
        /// </summary>
        /// <returns></returns>
        Task<int> GetMyTodoListCount();
        /// <summary>
        /// 首页 待办 详情页
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageListSearchResultVM<MyTodoListDetail>> GetTodoListDetailForCurrentUser(GetToDoListDetailByTab input);
      

        /// <summary>
        /// 远程搜索
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        Task<IReadOnlyList<SearchByUrlResponse>> SearchByUrl(string url);

        /// <summary>
        /// 获取我已审核的数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<List<string>> GetUserProcessedBizOrderId(QueryRequest request);
        
        /// <summary>
        /// 我提交的审批
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<List<string>> GetUserCreateApplyBizOrderId(QueryRequest request);

        /// <summary>
        /// 审批转交
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> PassOn(PassOnRequest request);

        /// <summary>
        /// 审批退回
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<NodeInfo> SendBack(SendBackRequest request);

        /// <summary>
        /// 审批单列表
        /// </summary>
        /// <param name="searchCondition"></param>
        /// <returns></returns>
        Task<PageListSearchResultVM<JJInstanceViewModel>> GetInstancePageList(JJInstanceSearchCondition searchCondition);

        /// <summary>
        /// 用户是否有审核数据权限
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<UserPowerResponse> CheckUserPower(CheckQueryRequest request);

        /// <summary>
        /// 审批转交（根据审批单据转交）
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<bool> TransferFlowsAsync(TransferFlowsInput input);

        /// <summary>
        /// 同步飞书三方审批
        /// </summary>
        /// <param name="instanceId">实例id</param>
        /// <param name="transferEmpId">被转交的EmpId(非转交时为空)</param>
        /// <returns></returns>
        Task SyncFeiShu(int instanceId, int? transferEmpId = null);
    }
}